<template>
    <div class="background">
        <Header></Header>
        <!-- <div class="waveWrapperInner bgTop"> -->
        <div class="wave waveTop bgTop"
            style="background-image: url('http://front-end-noobs.com/jecko/img/wave-top.png');"></div>
        <!-- </div> -->
        <!-- <div class="waveWrapperInner bgMiddle"> -->
        <div class="wave waveMiddle bgMiddle"
            style="background-image: url('http://front-end-noobs.com/jecko/img/wave-mid.png');"></div>
        <!-- </div> -->
        <!-- <div class="waveWrapperInner bgBottom"> -->
        <div class="wave waveBottom bgBottom"
            style="background-image: url('http://front-end-noobs.com/jecko/img/wave-bot.png');"></div>
        <!-- </div> -->
    </div>
    <router-view></router-view>

    <Footer />

</template>

<script setup>
import { onMounted } from 'vue';
import Header from './components/ComponentHeader.vue';
import Footer from './components/Footer.vue';


// 背景切换
let currentImgIndex = Math.floor(Math.random() * 32); // 初始随机图片索引
const totalImages = import.meta.env.VITE_IMAGE_COUNT; // 总图片数量
let backgroundElements;
function updateBackground() {

    currentImgIndex = (currentImgIndex + 1) % (totalImages + 1);
    if (backgroundElements.length >= 0) {
        backgroundElements[0].style.backgroundImage = `url(${import.meta.env.VITE_IMAGE_PATH}/${currentImgIndex}.gif)`;
    }

}
onMounted(() => {
    backgroundElements = document.querySelectorAll('.background');
    setInterval(updateBackground, 8000);
});

</script>
<style scoped>
.background {
    position: relative;
    width: 1519px;
    height: 684px;
    background-image: url("https://oss.littlestrange.site/conquer/image/26.gif");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: bottom;
    overflow: hidden;
    background-attachment: fixed;
    transition: all 3s;

}


.bgTop {
    z-index: 15;
    opacity: 0.5;
}

.bgMiddle {
    z-index: 10;
    opacity: 0.75;
}

.btBottom {
    z-index: 5;
}

.wave {
    position: absolute;
    left: 0;
    width: 200%;
    height: 100%;
    /* 是否重复 x轴重复，y轴不重复 */
    background-repeat: repeat no-repeat;
    /* 背景图片位置:底部 */
    background-position: 0 bottom;
    /* 图片运动过程中，以那个为中心点 */
    transform-origin: center bottom;
    overflow: hidden;
    top: -0.5px;

}

@keyframes move_wave {
    0% {
        transform: translateX(0) translateZ(0) scaleY(1)
    }

    50% {
        transform: translateX(-25%) translateZ(0) scaleY(0.55)
    }

    100% {
        transform: translateX(-50%) translateZ(0) scaleY(1)
    }
}


.waveTop {
    background-size: 50% 100px;
    animation: move_wave 3s;
    animation-delay: 1s;
}

.waveMiddle {
    background-size: 50% 120px;
    animation: move_wave 10s linear infinite;
}

.waveBottom {
    background-size: 50% 100px;
    animation: move_wave 15s linear infinite;
}
</style>
